// 菜品分类

import request from '@/utils/request'
import R from '@/types/conduit/R'
import { Page } from '@/types/param/page'
import DishCategory from '@/types/entity/DishCategory'
import { DishCategorySaveParam } from '@/types/param/dish-category'
export const queryList = (page: Page & { keyword: string }): Promise<R<{ total: number; listData: DishCategory[] }>> =>
  request({
    url: `/shop/dish-category/queryShopCategoryListPage`,
    method: 'GET',
    params: page
  })
export const removeShopDishCategory = (dishCategoryId: number): Promise<R<null>> =>
  request({
    url: `/shop/dish-category/removeShopDishCategory/${dishCategoryId}`,
    method: 'POST'
  })
export const getShopDishCategory = (dishCategoryId: number): Promise<R<null>> =>
  request({
    url: `/shop/dish-category/getShopDishCategory/${dishCategoryId}`,
    method: 'GET'
  })

export const saveDishCategory = (dishCategorySaveParam: DishCategorySaveParam): Promise<R<null>> => {
  return request({
    url: `/shop/dish-category/saveDishCategory`,
    method: 'POST',
    data: dishCategorySaveParam
  })
}

export const listShopDishCategory = (): Promise<R<DishCategory[]>> => {
  return request({
    url: `/shop/dish-category/listShopDishCategory`,
    method: 'GET'
  })
}
export const getDishCategoryTree = (shopId?: number): Promise<R<DishCategory[]>> =>
  request({
    url: `/shop/dish-category/dish-category-tree`,
    params: { shopId },
    method: 'GET'
  })
